/******************************************************************************
Project    : Real time rtsp server library base on live555
*******************************************************************************
File Name    :  <Mp2TsRTimeFramedSource.h>:  mp2ts real time framed source head file
Module Name  :  
Description  :  None
History      :
 No.   Ver.     Date        Designed by  Comment
-----+--------+----------+------------+---------------------------------------
 001   0.00.01  05/29/2015  <3G@LIURENHUA>   <mp2ts real time framed source head file>
*******************************************************************************/
#ifndef _MP2TS_FRAMED_RTIME_SOURCE_H
#define _MP2TS_FRAMED_RTIME_SOURCE_H

#include <FramedSource.hh>
#ifdef LOCAL_SOCK_INPUT
#include <LocalUdpSocket.h>
#endif /* LOCAL_SOCK_INPUT */

#include "RealTimeRtspServer_common.h"

/******************************************************************************
  class declaration
 ******************************************************************************/
class Mp2TsRTimeFramedSource: public FramedSource
{
public:
	static Mp2TsRTimeFramedSource* createNew(
							UsageEnvironment & env,
#ifdef LOCAL_SOCK_INPUT
							const char  *pcIdentity,
							const u_int32_t unSBufSize,
							const u_int32_t unRBufSize,
#else
							queue_t *pstQue,
#endif /* LOCAL_SOCK_INPUT */
							unsigned preferredFrameSize = 0);
protected:
	Mp2TsRTimeFramedSource(
							UsageEnvironment & env,
#ifdef LOCAL_SOCK_INPUT
						       const char  *pcIdentity,
							const u_int32_t unSBufSize,
							const u_int32_t unRBufSize,
#else
							queue_t *pstQue,
#endif /* LOCAL_SOCK_INPUT */
							unsigned preferredFrameSize);
	
	virtual ~Mp2TsRTimeFramedSource();

	static void RTimeReadableHandler(
		Mp2TsRTimeFramedSource* source, int mask);
	void doRealTimeRead();

private:
	virtual void doGetNextFrame();
	virtual void doStopGettingFrames();

private:
	unsigned fPreferredFrameSize;
	Boolean fHaveStartedReading;
#ifdef LOCAL_SOCK_INPUT
	/* Local socket object pointer */
	LSOCK_OBJECT_st *pstServer;
#else
	queue_t *m_que;
	static int fHandID;
	int fObjHandID;
#endif /* LOCAL_SOCK_INPUT */
};
#endif /* _MP2TS_FRAMED_RTIME_SOURCE_H */
